var t = require;
var e = module;
var o = exports;
var a,
    i =
        (this && this.__extends) ||
        ((a = function (t, e) {
            return (a =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (t, e) {
                        t.__proto__ = e;
                    }) ||
                function (t, e) {
                    for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
                })(t, e);
        }),
        function (t, e) {
            a(t, e);
            function o() {
                this.constructor = t;
            }
            t.prototype = null === e ? Object.create(e) : ((o.prototype = e.prototype), new o());
        }),
    n =
        (this && this.__decorate) ||
        function (t, e, o, a) {
            var i,
                n = arguments.length,
                r = n < 3 ? e : null === a ? (a = Object.getOwnPropertyDescriptor(e, o)) : a;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, a);
            else
                for (var s = t.length - 1; s >= 0; s--)
                    (i = t[s]) && (r = (n < 3 ? i(r) : n > 3 ? i(e, o, r) : i(e, o)) || r);
            return n > 3 && r && Object.defineProperty(e, o, r), r;
        };
Object.defineProperty(o, "__esModule", {value: !0});
var r = t("UIConfig"),
    s = t("UIManager"),
    c = t("UIManager"),
    p = t("TimeViewNode"),
    l = cc._decorator,
    d = l.ccclass,
    u = l.property,
    h =
        (l.menu,
        (function (t) {
            i(e, t);
            function e() {
                var e = (null !== t && t.apply(this, arguments)) || this;
                e.nodeView = null;
                e.redView = null;
                e.sprite = null;
                e.timeViewNode = null;
                return e;
            }
            e.prototype.onLoad = function () {
                var t = this;
                if (this.canClick()) {
                    this.nodeView.active = !0;
                    EVUIEffView.on(EVUIEffView.clickInvate, this.updateIndex.bind(this), this);
                    this.updateView();
                    this.openGuild();
                    this.scheduleOnce(function () {
                        t.updateView();
                    }, 5);
                } else this.nodeView.active = !1;
            };
            e.prototype.openGuild = function () {
                if (!GuildCache.isOverOnceGuid(GuildCache.oncecheckId[4][1])) {
                    GuildCache.checkKey = GuildCache.oncecheckId[4][1];
                    GuildCache.overOnceGuid(GuildCache.oncecheckId[4][1]);
                    GuildCache.openGuildView();
                }
            };
            e.prototype.onDestroy = function () {
                EVUIEffView.offTarget(this);
            };
            e.prototype.updateIndex = function () {
                var t = this;
                this.scheduleOnce(function () {
                    t.updateView();
                });
            };
            e.prototype.updateView = function () {
                var t = GameDataValue.getInvateData();
                if (t) {
                    this.timeViewNode.node.active = !0;
                    this.redView.active = !1;
                    var e = t.time,
                        o = Math.max(0, CacheDataManager.invateMakeTime);
                    this.timeViewNode.checkView(e, o, this.moveTimeCall.bind(this));
                    SpriteView.setInvateSpriteView(this.sprite, !1);
                } else {
                    SpriteView.setInvateSpriteView(this.sprite, !0);
                    this.timeViewNode.node.active = !0;
                    if (Date.now() - GameDataValue.getInvateCdTime() >= CacheDataManager.invateTimeCd) {
                        this.nodeView.active = !0;
                        this.redView.active = !1;
                    } else {
                        this.nodeView.active = !0;
                        this.timeViewNode.node.active = !0;
                        this.redView.active = !1;
                        (e = GameDataValue.getInvateCdTime()), (o = Math.max(0, CacheDataManager.invateTimeCd));
                        this.timeViewNode.checkView(e, o, this.moveTimeOpenCall.bind(this));
                    }
                }
            };
            e.prototype.moveTimeOpenCall = function (t) {
                var e = this;
                "1" == t &&
                    this.scheduleOnce(function () {
                        e.updateView();
                    });
            };
            e.prototype.moveTimeCall = function (t) {
                if ("1" == t && GameDataValue.getInvateData()) {
                    var e = CacheDataManager.getInvateId();
                    GameDataValue.setInvateData(null, Date.now());
                    GameDataValue.updateInvateCdTime();
                    this.updateView();
                    TaskGameEvent.emit(TaskGameEvent.removeInvate, e);
                }
            };
            e.prototype.clickItem = function () {
                this.canClick() &&
                    (Date.now() - GameDataValue.getInvateCdTime() >= CacheDataManager.invateTimeCd
                        ? GameDataValue.getInvateData()
                            ? s.default.open(r.UIID.UIInvateCatTip)
                            : c.default.open(r.UIID.UIInvateCat)
                        : s.default.open(r.UIID.UIToast, {msg: "邀请冷却中"}));
            };
            e.prototype.canClick = function () {
                return GameDataValue.getLastLv() >= 4;
            };
            n([u(cc.Node)], e.prototype, "nodeView", void 0);
            n([u(cc.Node)], e.prototype, "redView", void 0);
            n([u(cc.Sprite)], e.prototype, "sprite", void 0);
            n([u(p.default)], e.prototype, "timeViewNode", void 0);
            return n([d], e);
        })(cc.Component));
o.default = h;
